package com.rs.game.player.content;

import com.rs.cache.loaders.ItemDefinitions;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.game.player.QuestManager.Quests;

public class ItemConstants {

	public static int getDegradeItemWhenWear(int id) {
		// pvp armors
		if (id == 13958 || id == 13961 || id == 13964 || id == 13967 || id == 13970 || id == 13973 || id == 13858 || id == 13861 || id == 13864 || id == 13867 || id == 13870 || id == 13873 || id == 13876 || id == 13884 || id == 13887 || id == 13890 || id == 13893 || id == 13896 || id == 13899 || id == 13902 || id == 13905 || id == 13908 || id == 13911 || id == 13914 || id == 13917 || id == 13920 || id == 13923 || id == 13926 || id == 13929 || id == 13932 || id == 13935 || id == 13938 || id == 13941 || id == 13944 || id == 13947 || id == 13950 || id == 13958)
			return id + 2; // if you wear it it becomes corrupted LOL
		return -1;
	}

	// return amt of charges
	public static int getItemDefaultCharges(int id) {
		// pvp armors
		if (id == 13910 || id == 13913 || id == 13916 || id == 13919 || id == 13922 || id == 13925 || id == 13928 || id == 13931 || id == 13934 || id == 13937 || id == 13940 || id == 13943 || id == 13946 || id == 13949 || id == 13952)
			return 1500;
		if (id == 13960 || id == 13963 || id == 13966 || id == 13969 || id == 13972 || id == 13975)
			return 3000;
		if (id == 13860 || id == 13863 || id == 13866 || id == 13869 || id == 13872 || id == 13875 || id == 13878 || id == 13886 || id == 13889 || id == 13892 || id == 13895 || id == 13898 || id == 13901 || id == 13904 || id == 13907 || id == 13960)
			return 6000; // 1hour
		// nex armors
		if (id == 20137 || id == 20141 || id == 20145 || id == 20149 || id == 20153 || id == 20157 || id == 20161 || id == 20165 || id == 20169 || id == 20173)
			return 60000;
		return -1;
	}

	// return what id it degrades to, -1 for disapear which is default so we
	// dont add -1
	public static int getItemDegrade(int id) {
		if (id == 11285) // DFS
			return 11283;
		// nex armors
		if (id == 20137 || id == 20141 || id == 20145 || id == 20149 || id == 20153 || id == 20157 || id == 20161 || id == 20165 || id == 20169 || id == 20173)
			return id + 1;
		return -1;
	}

	public static int getDegradeItemWhenCombating(int id) {
		// nex armors
		if (id == 20135 || id == 20139 || id == 20143 || id == 20147 || id == 20151 || id == 20155 || id == 20159 || id == 20163 || id == 20167 || id == 20171 || id == 24983 || id == 24977 || id == 24989 || id == 24974 || id == 24986 || id == 24980)
			return id + 2;
		return -1;
	}

	public static boolean itemDegradesWhileHit(int id) {
		if (id == 2550)
			return true;
		return false;
	}

	public static boolean itemDegradesWhileWearing(int id) {
		String name = ItemDefinitions.getItemDefinitions(id).getName().toLowerCase();
		if (name.contains("c. dragon") || name.contains("corrupt dragon") || name.contains("vesta's") || name.contains("statius'") || name.contains("morrigan's") || name.contains("zuriel's"))
			return true;
		return false;
	}

	public static boolean itemDegradesWhileCombating(int id) {
		String name = ItemDefinitions.getItemDefinitions(id).getName().toLowerCase();
		// nex armors
		if (name.contains("torva") || name.contains("pernix") || name.contains("virtux") || name.contains("zaryte"))
			return true;
		return false;
	}

	public static boolean canWear(Item item, Player player) {
		if (player.getRights() == 2)
			return true;
		if (item.getId() == 14642 || item.getId() == 14645 || item.getId() == 15433 || item.getId() == 15435 || item.getId() == 14641 || item.getId() == 15432 || item.getId() == 15434) {
			if (!player.getQuestManager().completedQuest(Quests.NOMADS_REQUIEM)) {
				player.getPackets().sendGameMessage("You need to have completed Nomad's Requiem miniquest to use this cape.");
				return false;
			}
		}
		if (item.getId() == 20770 || item.getId() == 20769) {
			if (!player.fishOutfit) {
				player.getPackets().sendGameMessage("You must have achieved the fish outfit to wear this cape.");
				return false;
			}
			if (!player.cookGaunt) {
				player.getPackets().sendGameMessage("You must have achieved the cooking gauntlets to wear this cape.");
				return false;
			}
			if (!player.lumberjackOutfit) {
				player.getPackets().sendGameMessage("You must have achieved the lumberjack outfit to wear this cape.");
				return false;
			}
			if (!player.fireRing) {
				player.getPackets().sendGameMessage("You must have achieved the ring of fire to wear this cape.");
				return false;
			}
			if (!player.flameGlove) {
				player.getPackets().sendGameMessage("You must have achieved the flame gloves to wear this cape.");
				return false;
			}
			if (!player.infernoAdze) {
				player.getPackets().sendGameMessage("You must have achieved the inferno adze to wear this cape.");
				return false;
			}
			if (!player.agileLegs) {
				player.getPackets().sendGameMessage("You must have achieved the agile legs to wear this cape.");
				return false;
			}
			if (!player.agileTop) {
				player.getPackets().sendGameMessage("You must have achieved the agile top to wear this cape.");
				return false;
			}
			if (!player.maxedCape) {
				player.getPackets().sendGameMessage("You must have achieved the max cape to wear this cape.");
				return false;
			}
			if (!player.getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) && !player.getQuestManager().completedQuest(Quests.LOST_CITY) && player.getQuestManager().completedQuest(Quests.DWARF_CANNON) && player.getQuestManager().completedQuest(Quests.RECIPE_FOR_DISASTER)) {
				player.getPackets().sendGameMessage("You need to have completed all quests to wear this cape.");
				return false;
			}
			if (!player.isCompletedFightKiln()) {
				player.getPackets().sendGameMessage("You must have completed the fight kiln to wear this cape.");
				return false;
			}
			if (!player.isCompletedFightCaves()) {
				player.getPackets().sendGameMessage("You must have completed the fight caves to wear this cape.");
				return false;
			}
			if (!player.isKilledQueenBlackDragon()) {
				player.getPackets().sendGameMessage("You must have defeated the Queen Black Dragon and obtained the first dragonkin journal to wear this cape.");
				return false;
			}
			if (player.barrowsCount < 50) {
				player.getPackets().sendGameMessage("You must have opened at least 50 barrows chests to wear this cape.");
				return false;
			}
			if (player.crystalChests < 50) {
				player.getPackets().sendGameMessage("You must have opened at least 50 crystal chests to wear this cape.");
				return false;
			}
			if (player.taskCount < 50) {
				player.getPackets().sendGameMessage("You must have completed at least 50 slayer tasks to wear this cape.");
				return false;
			}
		}
		if (item.getId() == 20763) {
			if (player.time >= 50) {
				return true;
			}
		player.getPackets().sendGameMessage("You need 50 hs of gameplay to wear this cape.");
		return false;
		}
		if (item.getId() == 24709) {
			if (player.time >= 1000) {
				return true;
			}
		player.getPackets().sendGameMessage("You need 1000 hs of gameplay to wear this cape.");
		return false;
		}
		if (item.getId() == 20771 || item.getId() == 20772) {
			if (!player.fishOutfit) {
				player.getPackets().sendGameMessage("You must have achieved the fish outfit to wear this cape.");
				return false;
			}
			if (!player.cookGaunt) {
				player.getPackets().sendGameMessage("You must have achieved the cooking gauntlets to wear this cape.");
				return false;
			}
			if (!player.lumberjackOutfit) {
				player.getPackets().sendGameMessage("You must have achieved the lumberjack outfit to wear this cape.");
				return false;
			}
			if (!player.fireRing) {
				player.getPackets().sendGameMessage("You must have achieved the ring of fire to wear this cape.");
				return false;
			}
			if (!player.flameGlove) {
				player.getPackets().sendGameMessage("You must have achieved the flame gloves to wear this cape.");
				return false;
			}
			if (!player.infernoAdze) {
				player.getPackets().sendGameMessage("You must have achieved the inferno adze to wear this cape.");
				return false;
			}
			if (!player.agileLegs) {
				player.getPackets().sendGameMessage("You must have achieved the agile legs to wear this cape.");
				return false;
			}
			if (!player.agileTop) {
				player.getPackets().sendGameMessage("You must have achieved the agile top to wear this cape.");
				return false;
			}
			if (!player.maxedCape) {
				player.getPackets().sendGameMessage("You must have achieved the max cape to wear this cape.");
				return false;
			}
			if (!player.getQuestManager().completedQuest(Quests.NOMADS_REQUIEM) && !player.getQuestManager().completedQuest(Quests.LOST_CITY) && player.getQuestManager().completedQuest(Quests.DWARF_CANNON) && player.getQuestManager().completedQuest(Quests.RECIPE_FOR_DISASTER)) {
				player.getPackets().sendGameMessage("You need to have completed all quests to wear this cape.");
				return false;
			}
			if (!player.isCompletedFightKiln()) {
				player.getPackets().sendGameMessage("You must have completed the fight kiln to wear this cape.");
				return false;
			}
			if (!player.isCompletedFightCaves()) {
				player.getPackets().sendGameMessage("You must have completed the fight caves to wear this cape.");
				return false;
			}
			if (!player.isKilledQueenBlackDragon()) {
				player.getPackets().sendGameMessage("You must have defeated the Queen Black Dragon and obtained the first dragonkin journal to wear this cape.");
				return false;
			}
			if (player.barrowsCount < 100) {
				player.getPackets().sendGameMessage("You must have opened at least 100 barrows chests to wear this cape.");
				return false;
			}
			if (player.crystalChests < 100) {
				player.getPackets().sendGameMessage("You must have opened at least 100 crystal chests to wear this cape.");
				return false;
			}
			if (player.taskCount < 100) {
				player.getPackets().sendGameMessage("You must have completed at least 100 slayer tasks to wear this cape.");
				return false;
			}
		}
		if (item.getId() == 10551) {
			if (!player.getQuestManager().completedQuest(Quests.LOST_CITY)) {
				player.getPackets().sendGameMessage("You must have completed the Lost City quest to equip this.");
				return false;
			}
		}
		if (item.getId() == 14936) {
			if (!player.agileTop) {
				player.getPackets().sendGameMessage("You have not unlocked the agile top yet.");
				return false;
			}
		}
		if (item.getId() == 14938) {
			if (!player.agileLegs) {
				player.getPackets().sendGameMessage("You have not unlocked the agile legs yet.");
				return false;
			}
		}
		if (item.getId() == 24427 || item.getId() == 24428 || item.getId() == 24429 || item.getId() == 24430) {
			if (!player.fishOutfit) {
				player.getPackets().sendGameMessage("You have not unlocked the fishing outfit yet.");
				return false;
			}
		}
		if (item.getId() == 775) {
			if (!player.cookGaunt) {
				player.getPackets().sendGameMessage("You have not unlocked the cooking gauntlets yet.");
				return false;
			}
		}
		if (item.getId() == 10933 || item.getId() == 10939 || item.getId() == 10940 || item.getId() == 10941 || item.getId() == 10945) {
			if (!player.lumberjackOutfit) {
				player.getPackets().sendGameMessage("You have not unlocked the fishing outfit yet.");
				return false;
			}
		}
		if (item.getId() == 13659) {
			if (!player.fireRing) {
				player.getPackets().sendGameMessage("You have not unlocked the ring of fire yet.");
				return false;
			}
		}
		if (item.getId() == 13660) {
			if (!player.flameGlove) {
				player.getPackets().sendGameMessage("You have not unlocked the flame gloves yet.");
				return false;
			}
		}
		if (item.getId() == 13661) {
			if (!player.infernoAdze) {
				player.getPackets().sendGameMessage("You have not unlocked the inferno adze yet.");
				return false;
			}
		}
		if (item.getId() == 20747 || item.getId() == 20767) {
			if (!player.maxedCape) {
				player.getPackets().sendGameMessage("You need to have 99 in every skill to equip this cape.");
				return false;
			}
		}
		// String itemName = item.getName();
		/*
		 * if (itemName.contains("goliath gloves") ||
		 * itemName.contains("spellcaster glove") ||
		 * itemName.contains("swift glove")) { if
		 * (player.getDominionTower().getKilledBossesCount() < 50) {
		 * player.getPackets().sendGameMessage(
		 * "You need to have kill atleast 50 bosses in the Dominion tower to wear these gloves."
		 * ); return true; } }
		 */
		return true;
	}

	public static boolean isTradeable(Item item) {
		if (item.getDefinitions().getName().toLowerCase().contains("flaming skull"))
			return false;
		String name = ItemDefinitions.getItemDefinitions(item.getId()).getName().toLowerCase();
		if (name.contains("lucky") || name.contains("fist of guthix") || name.contains("defender") || name.contains("golden_mining"))
			return false;
		if (name.contains("charm")) {
			return false;
		}
		switch (item.getId()) {
		case 6570: // firecape
		case 6529: // tokkul
		case 24155:
		case 20767: // max cape
		case 20768:
		case 20748:
		case 20749:
		case 20752:
		case 20753:
		case 20754:
		case 20769:
		case 20770:
		case 20771:
		case 20772:
		case 24154:
		case 23659: // tookhaar-kal
		case 6746:
		case 10551:
			return false;
		default:
			return true;
		}
	}
}
